#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>



using namespace std;

//https://www.luogu.com.cn/problem/P2670


const int N = 110;

char matrix[N][N];
int n, m;

int dx[] = { 1,-1,0,0,1,-1,1,-1 };
int dy[] = { -1,1,1,-1,0,0,1,-1 };


int out[N][N];

int main()
{
	cin >> n >> m;

	for(int i=1 ; i<= n ; ++i)
		for (int j = 1; j <= m; ++j)
		{
			cin>>matrix[i][j];
			if (matrix[i][j] == '*')out[i][j] = -1;
		}

	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
		{
			if (matrix[i][j] == '?')
			{
				for(int k = 0 ; k < 8 ; ++k)
					out[i][j] += (out[i + dx[k]][j + dy[k]] == -1);
			}
			else
			{
				out[i][j] = -1;
			}
		}

	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			if (out[i][j] == -1)cout << '*';
			else cout << out[i][j];
		}cout << endl;
	}


	return 0;
}
